//
//  CarHelperCell.swift
//  Automobile
//
//  Created by erkebulan elzhan on 8/21/20.
//  Copyright © 2020 erkebulan elzhan. All rights reserved.
//

import UIKit

final class CarHelperCell: UITableViewCell, ConfigurableCell {

    // MARK: - Outlets

    private lazy var bannerView: UIView = {
        let view = UIView ()
        view.backgroundColor = .rgb(229, 233, 242)
        view.layer.cornerRadius = 7
        return view
    }()
    
    private lazy var bannerImgView: UIImageView = {
        let imgView = UIImageView()
        imgView.contentMode = .scaleAspectFill
        imgView.image = UIImage(named: "techGirl")
        return imgView
    }()
    
    private lazy var titleLbl: UILabel = {
        let lbl = UILabel ()
        lbl.font = .systemFont(ofSize: 14)
        lbl.textColor = .rgb(17, 100, 180)
        lbl.sizeToFit()
        lbl.numberOfLines = 0
        lbl.text = "Нужна помощь с выбором авто?"
        return lbl
    }()
    
    private lazy var helperBtn: UIButton = {
        let btn = UIButton()
        btn.backgroundColor = .rgb(253, 223, 89)
        btn.layer.cornerRadius = 20
        
        btn.titleLabel?.font = .systemFont(ofSize: 15, weight: .bold)
        btn.setTitleColor(.darkBlueColor, for: .normal)
        btn.setTitle("Написать помощнику", for: .normal)
        return btn
    }()
    
    // MARK: - Init
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.addViews()
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func configure(data object: Any?, index: Int) {
        
    }

    func returnData() -> Any? {
        return nil
    }
    
    
    private func addViews () {
        contentView.backgroundColor = .clear
        self.backgroundColor = .clear
        
        contentView.addSubview(bannerView)
        bannerView.addSubview(bannerImgView)
        bannerView.addSubview(titleLbl)
        bannerView.addSubview(helperBtn)
        
        
        bannerView.snp.makeConstraints { (make) in
            make.top.bottom.equalToSuperview().inset(12)
            make.leading.trailing.equalToSuperview().inset(16)
        }
        
        bannerImgView.snp.makeConstraints { (make) in
            make.width.equalTo(100)
            make.height.equalTo(82)
            make.leading.equalToSuperview().inset(8)
            make.centerY.equalToSuperview()
            make.top.bottom.equalToSuperview().inset(30)
        }
        
        titleLbl.snp.makeConstraints { (make) in
            make.top.equalTo(bannerImgView.snp.top)
            make.leading.equalTo(bannerImgView.snp.trailing).offset(20)
            make.trailing.equalToSuperview().inset(25)
        }
        
        helperBtn.snp.makeConstraints { (make) in
            make.trailing.equalToSuperview().inset(20)
            make.top.equalTo(titleLbl.snp.bottom).offset(12)
            make.height.equalTo(40)
            make.leading.equalTo(bannerImgView.snp.trailing).offset(12)
        }
        
    }
}
